package com.chen.servlet;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

@WebServlet("/servletB")
public class ServletB extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        // 向三大域中获取数据
        // 获取请求域中的数据
        String raqMsg = (String) req.getAttribute("req");
        System.out.println(raqMsg);

        // 获取session域的数据
        HttpSession session = req.getSession();
        System.out.println(session.getAttribute("session"));

        // 应用域中获取数据
        ServletContext application = getServletContext();
        System.out.println(application.getAttribute("application"));

    }
}
